package com.tjp.user.service.impl;

import com.tjp.page.PageResponse;
import com.tjp.user.bo.AuthUserBO;
import com.tjp.user.convert.AuthUserBoConvert;
import com.tjp.user.dto.AuthUserDTO;
import com.tjp.user.entity.AuthUser;
import com.tjp.user.mapper.AuthUserMapper;
import com.tjp.user.service.AuthUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: ape-frame
 * @description:
 * @author: aaronTang
 * @create: 2024-05-17
 */
@Service
public class AuthUserServiceImpl implements AuthUserService {

    @Resource
    private AuthUserMapper authUserMapper;

    @Override
    public PageResponse queryByPage(AuthUserBO authUserBO) {


        AuthUser authUser = AuthUserBoConvert.INSTANCE.convertAuthUserBoToEntity(authUserBO);
        List<AuthUser> authUsers = authUserMapper.queryPage(authUser, authUserBO.getPageNo(), authUserBO.getPageSize());

        PageResponse pageResponse = new PageResponse<>();
        pageResponse.setCurrent(authUserBO.getPageNo());
        pageResponse.setPageSize(authUserBO.getPageSize());
        Long pageStart = pageResponse.getPageStart();
        long total = authUsers.stream().count();

        pageResponse.setTotal(total);
        pageResponse.setRecords(authUsers);
        return pageResponse;
    }
}
